package com.zy.design.state.common;

/**
 * @author zhaoyi
 * @date 2021/9/23 12:00
 * 更加通用的
 *
 * 状态转移也比较简单，
 * 但事件触发执行的动作包含的业务逻辑可能会比较复杂，
 * 更加推荐使用状态模式来实现。
 *
 */
public class MStateMachine {
    //得分
    private int score;

    //当前状态
    private IMario mario;

    public MStateMachine() {
        this.score = 0;
        this.mario =  SmallMario.getInstance();
    }

    public MStateMachine(int score, IMario mario) {
        this.score = score;
        this.mario = mario;
    }


    //吃蘑菇
    public void eatMustRoom(){
        mario.eatMustRoom(this);
    }

    //获得斗篷
    public void eatCape(){
        mario.eatCape(this);
    }

    //获得火焰
    public void eatFire(){
        mario.eatFire(this);
    }

    //遇怪
    public void monster() {
        mario.monster(this);
    }



    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }

    public void setMario(IMario mario) {
        this.mario = mario;
    }

    @Override
    public String toString() {
        return "MStateMachine{" +
                "score=" + score +
                ", mario=" + mario.getStatus() +
                '}';
    }
}
